<?php
/**
 * Author: small-qiutian
 * E-mail: qiutian@fengyumeng.com
 */
namespace App;
class Log{

    /**
     * 记录日志
     * @param string $level  debug -> info -> notice -> warning -> error -> critical -> alert -> emergency
     * @param string $content
     */
    static function log($level = '',$content = '')
    {
        if(!$content){
            $content = $level;
            $level = 'debug';
        }
        if(is_array($content)){
            $content = json_encode($content,JSON_UNESCAPED_UNICODE);
        }
        if(is_object($content)){
            $content = $content->getFile().'【'.$content->getLine().'】:'.$content->getMessage();
        }
        \SeasLog::$level($content);
    }

    /**
     * 获取日志条数
     * @param string $level
     * @param string $time
     * @return mixed
     */
    static function count($level = '',$time = '')
    {
        $time = $time ? date('Ymd',strtotime($time)) : '';
        return \Seaslog::analyzerCount($level,$time);
    }

    /**
     * 读取日志
     * @param string $level
     * @param string $time
     * @return string
     */
    static function red($level = '',$time = '')
    {
        if(!$level){
            return 'param is debug|info|notice|warning|error|critical|alert|emergency';
        }
        $time = $time ? date('Ymd',strtotime($time)) : '';
        return \Seaslog::analyzerDetail($level,$time);
    }

    static function setBasePath($path)
    {
        if(!$path){
            return;
        }
        \Seaslog::setBasePath($path);
    }

    static function getBasePath()
    {
        return \Seaslog::getBasePath();
    }

    static function setLogger($path)
    {
        if(!$path){
            return;
        }
        \Seaslog::setLogger($path);
    }

    static function getLastLogger()
    {
        return \Seaslog::getLastLogger();
    }

}